<?php
include("./config/session-action.php");
include("./config/config.inc.php");
include("./config/QuickMySQL.php");
/*防毒墙用户的操作*/
class CUserVmAction extends JsonBase
{
	/*删除指定用户*/
	function Ondelselect(){
		$ids = explode(";", trim($_POST["ids"], ";"));
		$newids = "";
		foreach($ids as &$id){
			if("" != $newids)
				$newids .= ",";
			$newids .= (int)$id;
		}
		$sql = "delete from t_user_vm2 where id in ({$newids})";
		if( QuickMySQL::quickExecute($sql) ){
			$this->json["success"] = true;
			$this->json["msg"] = "删除成功";
		} else {
			$this->json["msg"] = "删除失败";
		}
	}
	/*删除所有用户*/
	function Ondelall(){
		$sql = "delete from t_user_vm2";
		if( QuickMySQL::quickExecute($sql) ){
			$this->json["success"] = true;
			$this->json["msg"] = "删除所有用户成功";
		} else {
			$this->json["msg"] = "删除所有用户失败";
		}
	}
	/*添加新用户*/
	function Onadd(){
		$company = str_replace("'", "''", $_POST["name"]);
		$email = str_replace("'", "''", $_POST["email"]);
		$phone = str_replace("'", "''", $_POST["phone"]);
		$lastdt = str_replace("'", "''", $_POST["lasttime"]);
		$sql = "insert into t_user_vm2(company,email,phone,lastdt) values('{$company}','{$email}','{$phone}','{$lastdt}')";
		if( QuickMySQL::quickExecute($sql) ){
			$this->json["success"] = true;
			$this->json["msg"] = "清加新用户成功";
		} else {
			$this->json["msg"] = "清加新用户失败";
		}
	}
	/*修改用户*/
	function Onmodify(){
		$ret["msg"] = "未实现";
		$company = str_replace("'", "''", $_POST["name"]);
		$email = str_replace("'", "''", $_POST["email"]);
		$phone = str_replace("'", "''", $_POST["phone"]);
		$lastdt = str_replace("'", "''", $_POST["lasttime"]);
		$id = (int)$_POST["id"];
		$sql = "update t_user_vm2 set company='{$company}',email='{$email}',phone='{$phone}',lastdt='{$lastdt}' where id={$id}";
		if( QuickMySQL::quickExecute($sql) ){
			$this->json["success"] = true;
			$this->json["msg"] = "修改失败";
		} else {
			$this->json["msg"] = "修改成功";
		}		
	}
}

$cc = new CUserVmAction();
?>